/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 * 02111-1307, USA.
 *
 * http://www.gnu.org/copyleft/gpl.html
 */
package com.l2jfrozen.gameserver.ai.special;

import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.quest.Quest;
import java.util.ArrayList;
import java.util.List;

/**
 * @author WhatEver
 */
public class RebornCorpse extends Quest implements Runnable
{
	List<L2NpcInstance> _currentMobs = new ArrayList<L2NpcInstance>();
	int _activePhase = 0;

	public RebornCorpse(int questId, String name, String descr)
	{
		super(questId, name, descr);
		int[] mobsKill ={21336, 21378, 21381};

		for(int mob : mobsKill)
			{addEventId(mob, Quest.QuestEventType.ON_KILL);}
	}

	@Override
	public String onKill(L2NpcInstance npc, L2PcInstance killer, boolean isPet)
	{
		_currentMobs.remove(npc);
		if(_currentMobs.isEmpty())
			nextPhase();
		return null;
	}

	private void nextPhase()
	{
		_activePhase++;
		
		if(_activePhase > 3) 
			_activePhase = 1;

		//@TODO
		// NextPhase waiter(120)
		// Fix coord, add Rnd +50

		switch(_activePhase)
		{
			case 1:
				_currentMobs.add(addSpawn(21336, 119319, 112238, -3695, 9074, false, 0));
				_currentMobs.add(addSpawn(21336, 119247, 112349, -3691, 9438, false, 0));
				_currentMobs.add(addSpawn(21336, 119225, 112176, -3698, 7247, false, 0));
				_currentMobs.add(addSpawn(21336, 119139, 112318, -3690, 6712, false, 0));
				break;
			case 2:
				_currentMobs.add(addSpawn(21378, 119319, 112238, -3695, 9074, false, 0));
				_currentMobs.add(addSpawn(21378, 119247, 112349, -3691, 9438, false, 0));
				_currentMobs.add(addSpawn(21378, 119225, 112176, -3698, 7247, false, 0));
				_currentMobs.add(addSpawn(21378, 119139, 112318, -3690, 6712, false, 0));
				break;
			case 3:
				_currentMobs.add(addSpawn(21381, 119319, 112238, -3695, 9074, false, 0));
				_currentMobs.add(addSpawn(21381, 119247, 112349, -3691, 9438, false, 0));
				_currentMobs.add(addSpawn(21381, 119225, 112176, -3698, 7247, false, 0));
				_currentMobs.add(addSpawn(21381, 119139, 112318, -3690, 6712, false, 0));
				break;
		}
	}

	@Override
	public void run()
		{nextPhase();}
}